package com.FTP;

import java.io.File;
import java.net.InetAddress;
import java.util.HashMap;
import java.util.Map;
/**
 * for each event, there is a list of ftp clients and one ftp server
 * the ftp clients are used to push files to the mobile
 * the ftp server is used to store all the files 
 * @author Chonglei
 *
 */
public class Event {
	
	private Map<ftpClient,Account> clients = new HashMap<ftpClient,Account>();
	public ftpServer server;
	
	public Location locl;
	public String name;
	public int port;
	public int count =0;
	public double radius = 1.0;
	public double expTime;
	
	public Event(Location ll,String name, String path, int newport)
	{
		File dirFile =new File(path);
		if(!(dirFile.exists()) || !(dirFile.isDirectory()))
		{
			dirFile.mkdir();
		}
		server = new ftpServer(port,path);
		locl =ll;
		this.name = name;
		this.port=newport;
	}
	/**
	 * set up the scope
	 * @param spec 
	 */
	public void setScope(double scope)
	{
		this.radius = scope;
	}
	
	public ftpClient addClient(Account account,InetAddress addr)
	{
		ftpClient client=new ftpClient(true);
		
		System.out.println("IP:"+addr.getHostAddress());
		
		client.setServerAddress(addr.getHostAddress());
		clients.put(client, account);
		return client;
	}
	public String getName()
	{
		return name;
	}
}
